home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /***************************************************************************
- *
- * @(#) - BZ - Multiplayer tank game.
- *
- * $Id: bzobjs.c,v 1.6 1993/08/11 19:46:08 adele Exp $
- *
- * Chris Fouts - Silicon Graphics, Inc.
- * October, 1991
- **************************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <math.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
-
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h>
- #include <Xm/Xm.h>
- #include <X11/Xirisw/GlxMDraw.h>
- #include <gl/gl.h>
- #include "bz.h"
- #include "bzobjs.h"
- #include "obstacles.h"
- #include "bzscreen.h"
-
- #define MV_COLOR(a,b) if( mv_RGB ) cpack(a) ; else color( b )
-
- long *longimagedata( const char *file ) ;
-
- /* BEGIN PROTOTYPES -S bzobjs.c */
- static void draw_tcirc( float x, float y, float r, int steps, int clip,
- int show_norms, float a ) ;
- static void make_ramp( Colormap cmap ) ;
- static void set_mapcolor( Colormap cmap, unsigned long i, unsigned short r,
- unsigned short g, unsigned short b ) ;
- static void show_logo( GL_Object logo, int type, int is_right, int side ) ;
- /* END PROTOTYPES -S bzobjs.c */
-
- static char *version_id = "$Id: bzobjs.c,v 1.6 1993/08/11 19:46:08 adele Exp $" ;
-
- static GL_Object obj_count = 1 ;
-
- #define OBSTACLE_MATERIAL 1
- #define GREEN_TANK_MATERIAL 2
- #define BLUE_TANK_MATERIAL 3
- #define RED_TANK_MATERIAL 4
- #define MISSILE_MATERIAL 5
- #define MAN_MATERIAL 6
-
- #define QX01 5.0 /* tank 0 coordinates */
- #define QX02 2.5
- #define QX03 0.0
- #define QX04 4./14.5
- #define QY01 -10.0
- #define QY02 -9.5
- #define QY03 -9.0
- #define QY04 -6.0
- #define QY05 -5.0
- #define QY06 0.0
- #define QY07 1./3.
- #define QY08 2./3.
- #define QY09 1.0
- #define QY10 5.0
- #define QY11 5.5
- #define QY12 6.0
- #define QY13 10.0
- #define QZ01 0.0
- #define QZ02 1.0
- #define QZ03 2.0
- #define QZ04 38./14.5
- #define QZ05 46./14.5
- #define QZ06 52./14.5
- #define QZ07 54./14.5
- #define QZ08 4.0
- #define QZ09 62./14.5
- #define QZ10 5.0
-
- #define PX01 5.0 /* tank 1 coordinates */
- #define PX02 2.5
- #define PX03 0.0
- #define PX04 2.5/9.
- #define PY01 -10.0
- #define PY02 -8.0
- #define PY03 -4.0
- #define PY04 1.1
- #define PY05 1.4
- #define PY06 1.7
- #define PY07 2.0
- #define PY08 10.0
- #define PY09 12.0
- #define PZ01 0.0
- #define PZ02 20./9.
- #define PZ03 25./9.
- #define PZ04 30./9.
- #define PZ05 35./9.
- #define PZ06 5.0
-
- #define RX01 5.0 /* tank 1 coordinates */
- #define RX02 2.5
- #define RX03 0.0
- #define RX04 2.5/9.
- #define RY01 -10.0
- #define RY02 -5.0
- #define RY03 -3.0
- #define RY04 17./9.
- #define RY05 23./9.
- #define RY06 33./9.
- #define RY07 39./9.
- #define RY08 8.0
- #define RY09 10.0
- #define RZ01 0.0
- #define RZ02 1.5
- #define RZ03 22./9.
- #define RZ04 25./9. /* gun barrel bot */
- #define RZ05 30./9. /* gun barrel top */
- #define RZ06 33./9.
- #define RZ07 36./9.
-
- #define MX01 0.25 /* missile coordinates */
- #define MX02 0.14
- #define MX03 0.00
- #define MY01 -1.00
- #define MY02 1.00
- #define MZ01 0.25
- #define MZ02 0.14
- #define MZ03 0.00
-
- #define FX00 0.0 /* flag coordinates */
- #define FX01 2.5
- #define FY00 0.0
- #define FY01 2.5
- #define FZ00 8.0
- #define FZ01 12.0
- #define FZ02 16.0
-
- #define NADA 0 /* nothing */
- #define BACK 1 /* back */
- #define RIGH 2 /* right */
- #define FRON 3 /* front */
- #define RPIT 4 /* right pit */
- #define RBAR 5 /* right barrel */
- #define FPIT 6 /* front pit */
- #define LPIT 7 /* left pit */
- #define LBAR 8 /* left barrel */
- #define LEFT 9 /* left */
- #define FBAR 10 /* front barrel */
- #define BPIT 11 /* back pit */
-
- extern Colorindex ramp0, ramp1, ramp2, ramp3, ramp4 ;
- extern Colorindex black, red, yellow, green, white, blue ;
- extern long over_mode ;
- extern Boolean mv_RGB ;
- extern Boolean use_textures ;
- Colorindex grey ;
- Colorindex o00 ;
- Colorindex o01 ;
- Colorindex o02 ;
- Colorindex o03 ;
- Colorindex o04 ;
- Colorindex o05 ;
- Colorindex o06 ;
- Colorindex o07 ;
- Colorindex t00[N_TEAMS] ;
- Colorindex t01[N_TEAMS] ;
- Colorindex t02[N_TEAMS] ;
- Colorindex t03[N_TEAMS] ;
- Colorindex t04[N_TEAMS] ;
- Colorindex t05[N_TEAMS] ;
- Colorindex t06[N_TEAMS] ;
- Colorindex t07[N_TEAMS] ;
- Colorindex m00 ;
- Colorindex m01 ;
- Colorindex m02 ;
- Colorindex m03 ;
- Colorindex ground_color ;
- unsigned long mv_black ;
- unsigned long mv_red ;
- unsigned long mv_green ;
- unsigned long mv_yellow ;
- unsigned long mv_white ;
- unsigned long mv_ground_color ;
- extern GL_Object flag_homes ;
- extern GL_Object null_obj ;
- extern float mv_w ;
- extern float mv_h ;
- extern float mv_m ;
- extern GL_Object mv_black_clear ;
- extern GL_Object mv_guided_bg ;
- extern GL_Object mv_normal_bg ;
- extern GL_Object mv_set_red ;
- extern GL_Object mv_set_yellow ;
- extern GL_Object mv_set_white ;
- extern GL_Object tank_logo[] ;
- extern int tank_logo_side[] ;
- extern GL_Object tank[N_TEAMS][N_TYPES][N_VIEWS] ;
- extern GL_Object missile[N_VIEWS] ;
- extern GL_Object crosshairs ;
- extern Matrix id_mat ;
- extern Boolean view_only ;
- extern GL_Object radar1 ;
- extern GL_Object ground ;
- extern GL_Object border ;
- extern GL_Object flag_homes_mv ;
- extern GL_Object sky ;
- extern GL_Object msl_expl[] ;
- extern GL_Object lights_on ;
- extern GL_Object lights_off ;
- extern Boolean transparentExplosion ;
- extern Boolean use_pups ;
- extern Display *display ;
- extern Widget toplevel ;
- extern Boolean db_base ;
- extern Boolean mv_RGB ;
- extern GL_Object digit[][2] ;
- extern GL_Object man_part ;
- extern GL_Object explosion[N_TEAMS][EXPDURATION][N_TYPES] ;
- extern Boolean showMan ;
- extern GL_Object cube[N_VIEWS] ;
- extern GL_Object pyrm[N_VIEWS] ;
- extern char *basename ;
- extern GL_Object flag[N_FLAGS][N_VIEWS] ;
- extern Boolean show_logos ;
-
-
-
- int order_tank_0[][11] = {
- {FBAR,RBAR,RPIT,BPIT,RIGH,BACK,NADA,NADA,NADA,NADA,NADA },
- {FBAR,RBAR,BPIT,RPIT,BACK,RIGH,NADA,NADA,NADA,NADA,NADA },
- {FRON,FPIT,FBAR,RBAR,RPIT,RIGH,NADA,NADA,NADA,NADA,NADA },
- {RIGH,FRON,RPIT,FPIT,RBAR,FBAR,NADA,NADA,NADA,NADA,NADA },
- {LEFT,FRON,LPIT,FPIT,LBAR,FBAR,NADA,NADA,NADA,NADA,NADA },
- {FRON,FPIT,FBAR,LBAR,LPIT,LEFT,NADA,NADA,NADA,NADA,NADA },
- {FBAR,LBAR,BPIT,LPIT,BACK,LEFT,NADA,NADA,NADA,NADA,NADA },
- {FBAR,LBAR,LPIT,BPIT,LEFT,BACK,NADA,NADA,NADA,NADA,NADA } } ;
-
- int order_tank_1[][10] = {
- {FPIT,RBAR,RPIT,FRON,RIGH,BACK,NADA,NADA,NADA,NADA },
- {FBAR,FPIT,RBAR,RPIT,BACK,RIGH,NADA,NADA,NADA,NADA },
- {FRON,FPIT,FBAR,RBAR,RPIT,RIGH,NADA,NADA,NADA,NADA },
- {RIGH,FRON,RPIT,FPIT,RBAR,FBAR,NADA,NADA,NADA,NADA },
- {LEFT,FRON,LPIT,FPIT,LBAR,FBAR,NADA,NADA,NADA,NADA },
- {FRON,FPIT,FBAR,LBAR,LPIT,LEFT,NADA,NADA,NADA,NADA },
- {FBAR,LBAR,FPIT,LPIT,BACK,LEFT,NADA,NADA,NADA,NADA },
- {LBAR,FPIT,LPIT,FRON,LEFT,BACK,NADA } } ;
-
- int order_obst[][4] = {
- {RIGH,BACK,NADA,NADA },
- {BACK,RIGH,NADA,NADA },
- {FRON,RIGH,NADA,NADA },
- {RIGH,FRON,NADA,NADA },
- {LEFT,FRON,NADA,NADA },
- {FRON,LEFT,NADA,NADA },
- {BACK,LEFT,NADA,NADA },
- {LEFT,BACK,NADA,NADA } } ;
-
- int order_missile[][4] = {
- {LEFT,RIGH,BACK,NADA },
- {LEFT,BACK,RIGH,NADA },
- {LEFT,FRON,RIGH,NADA },
- {LEFT,RIGH,FRON,NADA },
- {RIGH,LEFT,FRON,NADA },
- {RIGH,FRON,LEFT,NADA },
- {RIGH,BACK,LEFT,NADA },
- {RIGH,LEFT,BACK,NADA } } ;
-
- GL_Object back[N_TEAMS][N_TYPES] ;
- GL_Object right[N_TEAMS][N_TYPES] ;
- GL_Object front[N_TEAMS][N_TYPES] ;
- GL_Object right_pit[N_TEAMS][N_TYPES] ;
- GL_Object right_barrel[N_TEAMS][N_TYPES] ;
- GL_Object front_pit[N_TEAMS][N_TYPES] ;
- GL_Object left_pit[N_TEAMS][N_TYPES] ;
- GL_Object left_barrel[N_TEAMS][N_TYPES] ;
- GL_Object left[N_TEAMS][N_TYPES] ;
- GL_Object front_barrel[N_TEAMS][N_TYPES] ;
- GL_Object back_pit[N_TEAMS][N_TYPES] ;
- GL_Object tankMaterial[N_TEAMS] ;
-
- DECLARE( MVIEW ) ;
- DECLARE( RADAR ) ;
- DECLARE( HEAD ) ;
- DECLARE( LOADM ) ;
- DECLARE( READY ) ;
- DECLARE( SCORE ) ;
- DECLARE( LIVES ) ;
- DECLARE( LEVEL ) ;
- DECLARE( NOPLY ) ;
- DECLARE( RIGHT ) ;
- DECLARE( LEFTT ) ;
- DECLARE( MESGS ) ;
- DECLARE( OUTMS ) ;
- DECLARE( GROND ) ;
- DECLARE( LOGOD ) ;
- DECLARE( MINES ) ;
- DECLARE( FLAGS ) ;
-
- float missile_front_a[] = {
- 1.,
- 3.,
- MX02, MY01, MZ01,
- MX03, MY02, MZ03,
- -MX02, MY01, MZ01,
- } ;
- float missile_front_b[] = {
- 1.,
- 3.,
- -MX02, MY01,-MZ01,
- MX03, MY02, MZ03,
- MX02, MY01,-MZ01,
- } ;
- float missile_right[] = {
- 3.,
- 3.,
- MX01, MY01,-MZ02,
- MX02, MY01,-MZ01,
- MX03, MY02, MZ03,
- 3.,
- MX01, MY01, MZ02,
- MX01, MY01,-MZ02,
- MX03, MY02, MZ03,
- 3.,
- MX02, MY01, MZ01,
- MX01, MY01, MZ02,
- MX03, MY02, MZ03,
- } ;
- float missile_left[] = {
- 3.,
- 3.,
- -MX02, MY01,-MZ01,
- -MX01, MY01,-MZ02,
- MX03, MY02, MZ03,
- 3.,
- -MX01, MY01,-MZ02,
- -MX01, MY01, MZ02,
- MX03, MY02, MZ03,
- 3.,
- -MX01, MY01, MZ02,
- -MX02, MY01, MZ01,
- MX03, MY02, MZ03,
- } ;
- float missile_back[] = {
- 1.,
- 8.,
- -MX02, MY01,-MZ01,
- MX02, MY01,-MZ01,
- -MX01, MY01,-MZ02,
- MX01, MY01,-MZ02,
- -MX01, MY01, MZ02,
- MX01, MY01, MZ02,
- -MX02, MY01, MZ01,
- MX02, MY01, MZ01,
- } ;
-
- float tank0_back_a[] = {
- 1.,
- 4.,
- -QX01, QY02, QZ01,
- QX01, QY02, QZ01,
- -QX01, QY01, QZ03,
- QX01, QY01, QZ03,
- } ;
- float tank0_back_b[] = {
- 1.,
- 4.,
- -QX01, QY01, QZ03,
- QX01, QY01, QZ03,
- -QX01, QY03, QZ08,
- QX01, QY03, QZ08,
- } ;
- float tank0_right[] = {
- 1.,
- 6.,
- QX01, QY02, QZ01,
- QX01, QY10, QZ01,
- QX01, QY01, QZ03,
- QX01, QY12, QZ02,
- QX01, QY03, QZ08,
- QX01, QY11, QZ03,
- } ;
- float tank0_front_a[] = {
- 1.,
- 4.,
- -QX01, QY10, QZ01,
- -QX01, QY12, QZ02,
- QX01, QY10, QZ01,
- QX01, QY12, QZ02,
- } ;
- float tank0_front_b[] = {
- 1.,
- 4.,
- -QX01, QY12, QZ02,
- -QX01, QY11, QZ03,
- QX01, QY12, QZ02,
- QX01, QY11, QZ03,
- } ;
- float tank0_front_c[] = {
- 1.,
- 4.,
- -QX01, QY03, QZ08,
- QX01, QY03, QZ08,
- -QX01, QY11, QZ03,
- QX01, QY11, QZ03,
- } ;
- float tank0_rpit[] = {
- 1.,
- 4.,
- QX02, QY04, QZ06,
- QX02, QY09, QZ04,
- QX02, QY05, QZ10,
- QX02, QY06, QZ09,
- } ;
- float tank0_rbar[] = {
- 1.,
- 4.,
- QX04, QY08, QZ05,
- QX04, QY13, QZ05,
- QX04, QY07, QZ07,
- QX04, QY13, QZ07,
- } ;
- float tank0_fpit_a[] = {
- 1.,
- 4.,
- -QX02, QY05, QZ10,
- QX02, QY05, QZ10,
- -QX02, QY06, QZ09,
- QX02, QY06, QZ09,
- } ;
- float tank0_fpit_b[] = {
- 1.,
- 4.,
- -QX02, QY09, QZ04,
- -QX02, QY06, QZ09,
- QX02, QY09, QZ04,
- QX02, QY06, QZ09,
- } ;
- float tank0_lpit[] = {
- 1.,
- 4.,
- -QX02, QY04, QZ06,
- -QX02, QY05, QZ10,
- -QX02, QY09, QZ04,
- -QX02, QY06, QZ09,
- } ;
- float tank0_lbar[] = {
- 1.,
- 4.,
- -QX04, QY08, QZ05,
- -QX04, QY07, QZ07,
- -QX04, QY13, QZ05,
- -QX04, QY13, QZ07,
- } ;
- float tank0_left[] = {
- 1.,
- 6.,
- -QX01, QY12, QZ02,
- -QX01, QY10, QZ01,
- -QX01, QY11, QZ03,
- -QX01, QY02, QZ01,
- -QX01, QY03, QZ08,
- -QX01, QY01, QZ03,
- } ;
- float tank0_fbar[] = {
- 1.,
- 4.,
- -QX04, QY13, QZ05,
- -QX04, QY13, QZ07,
- QX04, QY13, QZ05,
- QX04, QY13, QZ07,
- } ;
- float tank0_bpit[] = {
- 1.,
- 4.,
- -QX02, QY04, QZ06,
- QX02, QY04, QZ06,
- -QX02, QY05, QZ10,
- QX02, QY05, QZ10,
- } ;
-
- float tank1_back[] = {
- 1.,
- 4.,
- -PX01, PY01, PZ01,
- PX01, PY01, PZ01,
- -PX01, PY02, PZ06,
- PX01, PY02, PZ06,
- } ;
- float tank1_right[] = {
- 1.,
- 3.,
- PX01, PY02, PZ06,
- PX01, PY01, PZ01,
- PX01, PY08, PZ01,
- } ;
- float tank1_front[] = {
- 1.,
- 4.,
- -PX01, PY02, PZ06,
- PX01, PY02, PZ06,
- -PX01, PY08, PZ01,
- PX01, PY08, PZ01,
- } ;
- float tank1_rpit[] = {
- 1.,
- 3.,
- PX02, PY04, PZ05,
- PX02, PY03, PZ05,
- PX02, PY07, PZ02,
- } ;
- float tank1_rbar[] = {
- 1.,
- 4.,
- PX04, PY06, PZ03,
- PX04, PY09, PZ03,
- PX04, PY05, PZ04,
- PX04, PY09, PZ04,
- } ;
- float tank1_fpit[] = {
- 1.,
- 4.,
- -PX02, PY07, PZ02,
- -PX02, PY04, PZ05,
- PX02, PY07, PZ02,
- PX02, PY04, PZ05,
- } ;
- float tank1_lpit[] = {
- 1.,
- 3.,
- -PX02, PY03, PZ05,
- -PX02, PY04, PZ05,
- -PX02, PY07, PZ02,
- } ;
- float tank1_lbar[] = {
- 1.,
- 4.,
- -PX04, PY06, PZ03,
- -PX04, PY05, PZ04,
- -PX04, PY09, PZ03,
- -PX04, PY09, PZ04,
- } ;
- float tank1_left[] = {
- 1.,
- 3.,
- -PX01, PY01, PZ01,
- -PX01, PY02, PZ06,
- -PX01, PY08, PZ01,
- } ;
- float tank1_fbar[] = {
- 1.,
- 4.,
- PX04, PY09, PZ03,
- -PX04, PY09, PZ03,
- PX04, PY09, PZ04,
- -PX04, PY09, PZ04,
- } ;
-
- float tank2_back[] = {
- 1.,
- 4.,
- -RX01, RY01, RZ01,
- RX01, RY01, RZ01,
- -RX01, RY02, RZ07,
- RX01, RY02, RZ07,
- } ;
- float tank2_right[] = {
- 1.,
- 4.,
- RX01, RY02, RZ07,
- RX01, RY01, RZ01,
- RX01, RY09, RZ02,
- RX01, RY08, RZ01,
- } ;
- float tank2_front_a[] = {
- 1.,
- 4.,
- -RX01, RY09, RZ02,
- RX01, RY09, RZ02,
- -RX01, RY08, RZ01,
- RX01, RY08, RZ01,
- } ;
- float tank2_front_b[] = {
- 1.,
- 4.,
- -RX01, RY02, RZ07,
- RX01, RY02, RZ07,
- -RX01, RY09, RZ02,
- RX01, RY09, RZ02,
- } ;
- float tank2_rpit[] = {
- 1.,
- 3.,
- RX02, RY04, RZ06,
- RX02, RY03, RZ06,
- RX02, RY07, RZ03,
- } ;
- float tank2_rbar[] = {
- 1.,
- 4.,
- RX04, RY05, RZ05,
- RX04, RY06, RZ04,
- RX04, RY09, RZ05,
- RX04, RY09, RZ04,
- } ;
- float tank2_fpit[] = {
- 1.,
- 4.,
- -RX02, RY07, RZ03,
- -RX02, RY04, RZ06,
- RX02, RY07, RZ03,
- RX02, RY04, RZ06,
- } ;
- float tank2_lpit[] = {
- 1.,
- 3.,
- -RX02, RY04, RZ06,
- -RX02, RY07, RZ03,
- -RX02, RY03, RZ06,
- } ;
- float tank2_lbar[] = {
- 1.,
- 4.,
- -RX04, RY05, RZ05,
- -RX04, RY09, RZ05,
- -RX04, RY06, RZ04,
- -RX04, RY09, RZ04,
- } ;
- float tank2_left[] = {
- 1.,
- 4.,
- -RX01, RY02, RZ07,
- -RX01, RY09, RZ02,
- -RX01, RY01, RZ01,
- -RX01, RY08, RZ01,
- } ;
- float tank2_fbar[] = {
- 1.,
- 4.,
- RX04, RY09, RZ04,
- -RX04, RY09, RZ04,
- RX04, RY09, RZ05,
- -RX04, RY09, RZ05,
- } ;
-
- float flag_front_top[] = {
- 1.,
- 3.,
- FX01, FY01, FZ01,
- -FX01, FY01, FZ01,
- FX00, FY00, FZ02,
- } ;
- float flag_front_bot[] = {
- 1.,
- 3.,
- FX01, FY01, FZ01,
- FX00, FY00, FZ00,
- -FX01, FY01, FZ01,
- } ;
- float flag_right_top[] = {
- 1.,
- 3.,
- FX01,-FY01, FZ01,
- FX01, FY01, FZ01,
- FX00, FY00, FZ02,
- } ;
- float flag_right_bot[] = {
- 1.,
- 3.,
- FX01,-FY01, FZ01,
- FX00, FY00, FZ00,
- FX01, FY01, FZ01,
- } ;
- float flag_left_top[] = {
- 1.,
- 3.,
- -FX01, FY01, FZ01,
- -FX01,-FY01, FZ01,
- FX00, FY00, FZ02,
- } ;
- float flag_left_bot[] = {
- 1.,
- 3.,
- -FX01, FY01, FZ01,
- FX00, FY00, FZ00,
- -FX01,-FY01, FZ01,
- } ;
- float flag_back_top[] = {
- 1.,
- 3.,
- -FX01,-FY01, FZ01,
- FX01,-FY01, FZ01,
- FX00, FY00, FZ02,
- } ;
- float flag_back_bot[] = {
- 1.,
- 3.,
- -FX01,-FY01, FZ01,
- FX00, FY00, FZ00,
- FX01,-FY01, FZ01,
- } ;
-
-
-
- void normal3f(
- float ny,
- float nx,
- float nz
- )
- {
- float n[3] ;
-
- n[0] = nx ;
- n[1] = ny ;
- n[2] = nz ;
-
- n3f( n ) ;
- }
-
-
-
- void set_normal(
- float *desc,
- int stride
- )
- {
- int i ;
- int j ;
- int k ;
- float a[3] ;
- float b[3] ;
- float n[3] ;
- float sum = 0. ;
-
- if( !mv_RGB ) return ;
-
- for( i = 0 ; i < 3 ; i++ ) {
- a[i] = desc[i ] - desc[i+stride] ;
- b[i] = desc[i+2*stride] - desc[i+stride] ;
- }
-
- for( i = 0 ; i < 3 ; i++ ) {
- j = ( i + 1 ) % 3 ;
- k = ( j + 1 ) % 3 ;
- n[i] = a[j] * b[k] - a[k] * b[j] ;
- sum += n[i] * n[i] ;
- }
-
- if( sum > 0.0 ) {
- sum = sqrtf( sum ) ;
- n[0] /= sum ;
- n[1] /= sum ;
- n[2] /= sum ;
- }
- else {
- fprintf( stderr, "zero normal!\n" ) ;
- }
-
- n3f( n ) ;
- }
-
-
-
- void draw_surface(
- float *desc
- )
- {
- int n_pnts ;
- int n_parts = (int)*(desc++) ;
-
- while( n_parts-- ) {
- n_pnts = (int)*(desc++) ;
- bgntmesh() ;
- set_normal( desc, 3 ) ;
- while( n_pnts-- ) {
- v3f( desc ) ;
- desc += 3 ;
- }
- endtmesh() ;
- }
- }
-
-
-
- void draw_tex_surface(
- float *desc
- )
- {
- int n_pnts ;
- int n_parts = (int)*(desc++) ;
-
- while( n_parts-- ) {
- n_pnts = (int)*(desc++) ;
- bgntmesh() ;
- set_normal( desc, 5 ) ;
- while( n_pnts-- ) {
- if( use_textures ) t2f( &(desc[3]) ) ;
- v3f( desc ) ;
- desc += 5 ;
- }
- endtmesh() ;
- }
- }
-
-
-
- void draw_dark_surface(
- float *desc
- )
- {
- int n_pnts ;
- int n_parts = (int)*(desc++) ;
- static float n[3] = { 0., 0., 1. } ;
-
- while( n_parts-- ) {
- n_pnts = (int)*(desc++) ;
- bgntmesh() ;
- if( mv_RGB ) cpack( 0x0 ) ;
- while( n_pnts-- ) {
- v3f( desc ) ;
- desc += 3 ;
- }
- endtmesh() ;
- }
- }
-
-
-
- void make_all( void )
- {
- make_fonts();
-
- makeobj( null_obj ) ;
- closeobj();
-
- makeobj( flag_homes = obj_count++ ) ;
- color( red ) ;
- rect( RED_FLAG_HOME_X - FLAG_HOME_PERIM,
- RED_FLAG_HOME_Y - FLAG_HOME_PERIM,
- RED_FLAG_HOME_X + FLAG_HOME_PERIM,
- RED_FLAG_HOME_Y + FLAG_HOME_PERIM ) ;
- color( blue ) ;
- rect( BLUE_FLAG_HOME_X - FLAG_HOME_PERIM,
- BLUE_FLAG_HOME_Y - FLAG_HOME_PERIM,
- BLUE_FLAG_HOME_X + FLAG_HOME_PERIM,
- BLUE_FLAG_HOME_Y + FLAG_HOME_PERIM ) ;
- closeobj() ;
- }
-
-
- void make_mv_objects( void )
- {
- make_tank() ;
- make_obst() ;
- make_missile() ;
- make_flags() ;
- make_crosshairs() ;
- make_ground() ;
- make_sky() ;
- make_expl() ;
- make_pieces( EXPDURATION ) ;
-
- makeobj( mv_black_clear = obj_count++ ) ;
- MV_COLOR( mv_black, black ) ;
- clear() ;
- closeobj() ;
-
- makeobj( mv_guided_bg = obj_count++ ) ;
- MV_COLOR( mv_red, red ) ;
- sboxf( 0., mv_m, mv_w, mv_h ) ;
- MV_COLOR( mv_ground_color, ground_color ) ;
- sboxf( 0., 0., mv_w, mv_m ) ;
- closeobj() ;
-
- makeobj( mv_normal_bg = obj_count++ ) ;
- MV_COLOR( mv_black, black ) ;
- sboxf( 0., mv_m, mv_w, mv_h ) ;
- MV_COLOR( mv_ground_color, ground_color ) ;
- sboxf( 0., 0., mv_w, mv_m ) ;
- closeobj() ;
-
- makeobj( mv_set_yellow = obj_count++ ) ;
- MV_COLOR( mv_yellow, yellow ) ;
- closeobj() ;
-
- makeobj( mv_set_red = obj_count++ ) ;
- MV_COLOR( mv_red, red ) ;
- closeobj() ;
-
- makeobj( mv_set_white = obj_count++ ) ;
- MV_COLOR( mv_white, white );
- closeobj() ;
- }
-
-
-
- void draw_tank(
- int type,
- int view,
- int k,
- int p
- )
- {
- int i ;
- int team ;
- int *order ;
-
- if( mv_RGB ) {
- team = 0 ;
- lmbind( MATERIAL, tankMaterial[k] ) ;
- }
- else {
- team = k ;
- }
-
- order = ( type ) ? order_tank_1[view] : order_tank_0[view] ;
-
- while( ( i = *(order++) ) != NADA ) {
- switch( i ) {
- case BACK:
- callobj( back[team][type] ) ;
- break;
- case RIGH:
- callobj( right[team][type] ) ;
- show_logo( tank_logo[p], type, 1, tank_logo_side[p] ) ;
- break;
- case FRON:
- callobj( front[team][type] ) ;
- break;
- case RPIT:
- callobj( right_pit[team][type] ) ;
- break;
- case RBAR:
- callobj( right_barrel[team][type] ) ;
- break;
- case FPIT:
- callobj( front_pit[team][type] ) ;
- break;
- case LPIT:
- callobj( left_pit[team][type] ) ;
- break;
- case LBAR:
- callobj( left_barrel[team][type] ) ;
- break;
- case LEFT:
- callobj( left[team][type] ) ;
- show_logo( tank_logo[p], type, 0, tank_logo_side[p] ) ;
- break;
- case FBAR:
- callobj( front_barrel[team][type] ) ;
- break;
- case BPIT:
- callobj( back_pit[team][type] ) ;
- break;
- default :
- fprintf( stderr, "draw_tank: bad data %d\n", i ) ;
- break;
- }
- }
- }
-
-
-
- void make_tank( void )
- {
- int team ;
-
- for( team = 0 ; team < ( ( mv_RGB ) ? 1 : N_TEAMS ) ; team++ ) {
-
- /* Tank body 0 */
- makeobj( back[team][0] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank0_back_a ) ;
- if( !mv_RGB ) color( t03[team] ) ;
- draw_surface( tank0_back_b ) ;
- closeobj() ;
-
- makeobj( right[team][0] = obj_count++ ) ;
- if( !mv_RGB ) color( t05[team] ) ;
- draw_surface( tank0_right ) ;
- closeobj() ;
-
- makeobj( front[team][0] = obj_count++ ) ;
- if( !mv_RGB ) color( t07[team] ) ;
- draw_surface( tank0_front_a ) ;
- if( !mv_RGB ) color( t02[team] ) ;
- draw_surface( tank0_front_b ) ;
- if( !mv_RGB ) color( t00[team] ) ;
- draw_surface( tank0_front_c ) ;
- closeobj() ;
-
- makeobj( right_pit[team][0] = obj_count++ ) ;
- if( !mv_RGB ) color( t05[team] ) ;
- draw_surface( tank0_rpit ) ;
- closeobj() ;
-
- makeobj( right_barrel[team][0] = obj_count++ ) ;
- if( !mv_RGB ) color( t05[team] ) ;
- draw_surface( tank0_rbar ) ;
- closeobj() ;
-
- makeobj( front_pit[team][0] = obj_count++ ) ;
- if( !mv_RGB ) color( t00[team] ) ;
- draw_surface( tank0_fpit_a ) ;
- if( !mv_RGB ) color( t01[team] ) ;
- draw_surface( tank0_fpit_b ) ;
- closeobj() ;
-
- makeobj( left_pit[team][0] = obj_count++ ) ;
- if( !mv_RGB ) color( t05[team] ) ;
- draw_surface( tank0_lpit ) ;
- closeobj() ;
-
- makeobj( left_barrel[team][0] = obj_count++ ) ;
- if( !mv_RGB ) color( t05[team] ) ;
- draw_surface( tank0_lbar ) ;
- closeobj() ;
-
- makeobj( left[team][0] = obj_count++ ) ;
- if( !mv_RGB ) color( t05[team] ) ;
- draw_surface( tank0_left ) ;
- closeobj() ;
-
- makeobj( front_barrel[team][0] = obj_count++ ) ;
- if( !mv_RGB ) color( black ) ;
- draw_dark_surface( tank0_fbar ) ;
- closeobj() ;
-
- makeobj( back_pit[team][0] = obj_count++ ) ;
- if( !mv_RGB ) color( t01[team] ) ;
- draw_surface( tank0_bpit ) ;
- closeobj() ;
-
-
- /* Tank body 1 */
- makeobj( back[team][1] = obj_count++ ) ;
- if( !mv_RGB ) color( t04[team] ) ;
- draw_surface( tank1_back ) ;
- closeobj() ;
-
- makeobj( right[team][1] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank1_right ) ;
- closeobj() ;
-
- makeobj( front[team][1] = obj_count++ ) ;
- if( !mv_RGB ) color( t00[team] ) ;
- draw_surface( tank1_front ) ;
- closeobj() ;
-
- makeobj( right_pit[team][1] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank1_rpit ) ;
- closeobj() ;
-
- makeobj( right_barrel[team][1] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank1_rbar ) ;
- closeobj() ;
-
- makeobj( front_pit[team][1] = obj_count++ ) ;
- if( !mv_RGB ) color( t02[team] ) ;
- draw_surface( tank1_fpit ) ;
- closeobj() ;
-
- makeobj( left_pit[team][1] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank1_lpit ) ;
- closeobj() ;
-
- makeobj( left_barrel[team][1] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank1_lbar ) ;
- closeobj() ;
-
- makeobj( left[team][1] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank1_left ) ;
- closeobj() ;
-
- makeobj( front_barrel[team][1] = obj_count++ ) ;
- if( !mv_RGB ) color( black ) ;
- draw_dark_surface( tank1_fbar ) ;
- closeobj() ;
-
- makeobj( back_pit[team][1] = obj_count++ ) ;
- closeobj() ;
-
-
- /* Tank body 2 */
- makeobj( back[team][2] = obj_count++ ) ;
- if( !mv_RGB ) color( t04[team] ) ;
- draw_surface( tank2_back ) ;
- closeobj() ;
-
- makeobj( right[team][2] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank2_right ) ;
- closeobj() ;
-
- makeobj( front[team][2] = obj_count++ ) ;
- if( !mv_RGB ) color( t07[team] ) ;
- draw_surface( tank2_front_a ) ;
- if( !mv_RGB ) color( t00[team] ) ;
- draw_surface( tank2_front_b ) ;
- closeobj() ;
-
- makeobj( right_pit[team][2] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank2_rpit ) ;
- closeobj() ;
-
- makeobj( right_barrel[team][2] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank2_rbar ) ;
- closeobj() ;
-
- makeobj( front_pit[team][2] = obj_count++ ) ;
- if( !mv_RGB ) color( t02[team] ) ;
- draw_surface( tank2_fpit ) ;
- closeobj() ;
-
- makeobj( left_pit[team][2] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank2_lpit ) ;
- closeobj() ;
-
- makeobj( left_barrel[team][2] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank2_lbar ) ;
- closeobj() ;
-
- makeobj( left[team][2] = obj_count++ ) ;
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( tank2_left ) ;
- closeobj() ;
-
- makeobj( front_barrel[team][2] = obj_count++ ) ;
- if( !mv_RGB ) color( black ) ;
- draw_dark_surface( tank2_fbar ) ;
- closeobj() ;
-
- makeobj( back_pit[team][2] = obj_count++ ) ;
- closeobj() ;
- }
- }
-
-
-
- void make_missile( void )
- {
- int i ;
- int v ;
-
- for( v = 0 ; v < N_VIEWS ; v++ ) {
- makeobj( missile[v] = obj_count++ ) ;
- if( mv_RGB )
- lmbind( MATERIAL, MISSILE_MATERIAL ) ;
- pushmatrix() ;
- translate( 0., 0., (QZ05 + QZ07) / 2. ) ;
- for( i = 0 ; i < 4 ; i++ ) {
- switch( order_missile[v][i] ) {
- case FRON:
- if( !mv_RGB ) color( m00 ) ;
- draw_surface( missile_front_a ) ;
- if( !mv_RGB ) color( m03 ) ;
- draw_surface( missile_front_b ) ;
- break;
- case RIGH:
- if( !mv_RGB ) color( m01 ) ;
- draw_surface( missile_right ) ;
- break;
- case LEFT:
- if( !mv_RGB ) color( m01 ) ;
- draw_surface( missile_left ) ;
- break;
- case BACK:
- if( !mv_RGB ) color( m02 ) ;
- draw_surface( missile_back ) ;
- break;
- case NADA:
- break;
- }
- }
- popmatrix() ;
- closeobj();
- }
- }
-
-
-
- void make_crosshairs( void )
- {
- int cxmid ;
- int cymid ;
- int cxdel ;
- float p[2] ;
-
- cxmid = ( VPMVIEW_R - VPMVIEW_L ) / 2 ;
- cymid = ( VPMVIEW_T - VPMVIEW_B ) / 2 ;
- cxdel = ( VPMVIEW_R - VPMVIEW_L ) / 200 ;
-
- makeobj( crosshairs = obj_count++ ) ;
- pushmatrix();
- loadmatrix( id_mat ) ;
- ortho2( 0., FVPMVIEW_R - FVPMVIEW_L, 0., FVPMVIEW_T - FVPMVIEW_B ) ;
- MV_COLOR( mv_yellow, yellow );
- bgnline() ;
- p[0] = (float)cxmid-cxdel ;
- p[1] = (float)cymid ;
- v2f( p ) ;
- p[0] = (float)cxmid+cxdel ;
- v2f( p ) ;
- endline() ;
- bgnline() ;
- p[0] = (float)cxmid ;
- p[1] = (float)cymid-cxdel ;
- v2f( p ) ;
- p[1] = (float)cymid+cxdel ;
- v2f( p ) ;
- endline() ;
- if( view_only )
- circ( (float)cxmid, (float)cymid, VIEW_ONLY_TRACK_RADIUS ) ;
- else
- circ( (float)cxmid, (float)cymid, NORMAL_TRACK_RADIUS ) ;
- popmatrix();
- closeobj() ;
- }
-
-
- void make_radar( void )
- {
- makeobj( radar1 = obj_count++ ) ;
- color( grey ) ;
- clear() ;
- color( 0 ) ;
- circf( 0., 0., GM_DURATN * GM_VEL / 10. ) ;
- closeobj() ;
- }
-
-
- void make_ground( void )
- {
- float pt[2] ;
- float i ;
- float j ;
-
- makeobj( ground = obj_count++ ) ;
- MV_COLOR( 0x00000000, black ) ;
- bgnpoint() ;
- for(i = -750. ; i <= 750. ; i+=50. ) {
- pt[0] = i ;
- for(j = -750. ; j <= 750. ; j+=50. ) {
- pt[1] = j ;
- v2f( pt ) ;
- }
- }
- endpoint() ;
- closeobj();
-
- makeobj( border = obj_count++ ) ;
- rect( -FIELD_SIZE, -FIELD_SIZE, FIELD_SIZE, FIELD_SIZE ) ;
- closeobj() ;
-
- makeobj( flag_homes_mv = obj_count++ ) ;
- MV_COLOR( 0x000000ff, red ) ;
- rect( RED_FLAG_HOME_X - FLAG_HOME_PERIM,
- RED_FLAG_HOME_Y - FLAG_HOME_PERIM,
- RED_FLAG_HOME_X + FLAG_HOME_PERIM,
- RED_FLAG_HOME_Y + FLAG_HOME_PERIM ) ;
- MV_COLOR( 0x00ff0000, blue ) ;
- rect( BLUE_FLAG_HOME_X - FLAG_HOME_PERIM,
- BLUE_FLAG_HOME_Y - FLAG_HOME_PERIM,
- BLUE_FLAG_HOME_X + FLAG_HOME_PERIM,
- BLUE_FLAG_HOME_Y + FLAG_HOME_PERIM ) ;
- closeobj() ;
- }
-
-
- void make_sky( void )
- {
- int i ;
- Angle phi ;
- Angle theta ;
- float xyz[3] ;
-
- makeobj( sky = obj_count++ ) ;
- MV_COLOR( mv_white, white );
- for( i = 0 ; i < 1000 ; i++ ) {
- phi = ( rand() % 50 ) ;
- theta = ( rand() % 3600 ) ;
- xyz[0] = 1000. * COSINE( phi ) * COSINE( theta ) ;
- xyz[1] = 1000. * COSINE( phi ) * SINE( theta ) ;
- xyz[2] = 1000. * SINE( phi ) ;
- if( i < 50 ) {
- cmov( xyz[0], xyz[1], xyz[2] ) ;
- charstr( "." ) ;
- }
- else {
- if( i == 50 )
- bgnpoint() ;
- v3f( xyz ) ;
- }
- }
- endpoint() ;
- closeobj();
- }
-
-
-
- static void draw_tcirc(
- float x,
- float y,
- float r,
- int steps,
- int clip,
- int show_norms,
- float a
- )
- {
- int i ;
- float ang ;
- float v[3] ;
- float denom = steps / 2 ;
- float rad ;
-
- bgntmesh() ;
- if( show_norms )
- normal3f( fsin( a )*fcos( 0. ), fsin( a )*fsin( 0. ), fcos( a ) ) ;
- v[0] = x + r ;
- v[1] = y + 0. ;
- v[2] = 0. ;
- v2f( v ) ;
- if( show_norms )
- normal3f( 0., 0., 1. ) ;
- v[0] = x + 0. ;
- v[1] = y + 0. ;
- v[2] = 0. ;
- v2f( v ) ;
- for( i = 1 ; i <= steps ; i++ ) {
- ang = i / denom * M_PI ;
- if( clip ) {
- rad = r * ( 1.0 + ( rand() % 11 - 5.0 ) * 0.01 ) ;
- }
- else {
- rad = r ;
- }
- v[0] = x + rad * fcos( ang ) ;
- v[1] = y + rad * fsin( ang ) ;
- v[2] = 0. ;
- if( clip && v[1] < -DROP ) {
- /*
- * Hack to make explosion look 3D.
- */
- v[2] = ( -DROP - v[1] ) * -fsin( ang ) ;
- v[1] = -DROP ;
- }
- if( show_norms )
- normal3f( fsin( a )*fcos( ang ), fsin( a )*fsin( ang ),
- fcos( a ) ) ;
- v3f( v ) ;
- swaptmesh() ;
- }
- endtmesh() ;
- }
-
-
-
- static float expl_c[][3] = {
- { 1.00, 1.00, 0.00 },
- { 1.00, 0.25, 0.00 },
- { 0.65, 0.00, 0.00 },
- { 0.25, 0.00, 0.00 },
- { 0.00, 0.00, 0.00 },
- } ;
-
- void make_expl( void )
- {
- int i ;
- int lo ;
- int hi ;
- float f ;
- float r ;
- float c[4] ;
-
- for( i = 0 ; i < MEXPL_DURATION ; i++ ) {
- makeobj( msl_expl[i] = obj_count++ ) ;
- r = 16. * fsin( ( ( i + 2. ) / MEXPL_DURATION ) * M_PI_2 ) ;
- if( mv_RGB ) {
- f = (float)i / ( MEXPL_DURATION - 1. ) ;
- f *= sizeof( expl_c ) / sizeof( expl_c[0] ) - 1 ;
- lo = (int)ffloor( f ) ;
- hi = (int)fceil( f ) ;
- f -= lo ;
- c[0] = expl_c[lo][0] + f*( expl_c[hi][0] - expl_c[lo][0] ) ;
- c[1] = expl_c[lo][1] + f*( expl_c[hi][1] - expl_c[lo][1] ) ;
- c[2] = expl_c[lo][2] + f*( expl_c[hi][2] - expl_c[lo][2] ) ;
- if( transparentExplosion ) {
- c[3] = sqrt( 1. - (float)i / ( MEXPL_DURATION - 1. ) ) ;
- c4f( c ) ;
- }
- else {
- c3f( c ) ;
- }
- }
- else {
- color( red );
- }
- pushmatrix() ;
- translate( 0., 0., DROP ) ;
- rotate( 900, 'x' ) ;
- if( transparentExplosion )
- blendfunction( BF_SA, BF_MSA ) ;
- else
- setpattern( 1 ) ;
- draw_tcirc( 0., 0., r, 30, 1, 0, 0. ) ;
- if( transparentExplosion )
- blendfunction( BF_ONE, BF_ZERO ) ;
- else
- setpattern( 0 ) ;
- popmatrix() ;
- closeobj();
- }
- }
-
-
-
- void init_overlay_color(
- Widget w
- )
- {
- int n ;
- Arg args[5] ;
- Colormap cmap ;
- Window wndw ;
- XVisualInfo *visualInfo ;
-
- grey = 1 ;
-
- n = 0 ;
- XtSetArg( args[n], ( use_pups ) ? GlxNpopupVisual : GlxNoverlayVisual,
- &visualInfo ) ; n++ ;
- XtSetArg( args[n], ( use_pups ) ? GlxNpopupWindow : GlxNoverlayWindow,
- &wndw ) ; n++ ;
- XtSetArg( args[n], ( use_pups ) ? GlxNpopupColormap : GlxNoverlayColormap,
- &cmap ) ; n++ ;
- XtGetValues( w, args, n ) ;
-
- /*
- * The following gives a BadAlloc error, so skip for now. It works anyway
- * without creating a new map (as of 4.0.3)....
- *
- cmap = XCreateColormap( XtDisplay( w ), wndw, visualInfo->visual,
- AllocNone ) ;
- n = 0 ;
- XtSetArg( args[n], ( use_pups ) ? GlxNpopupColormap : GlxNoverlayColormap,
- cmap ) ; n++ ;
- XtSetValues( w, args, n ) ;
- */
-
- set_mapcolor( cmap, grey, 120, 120, 120 ) ;
- set_mapcolor( cmap, 2, 255, 255, 0 ) ;
- }
-
-
-
- float ObstacleMaterial[] = {
- AMBIENT, 0.065, 0.038, 0.025,
- DIFFUSE, 0.650, 0.380, 0.250,
- SPECULAR, 0.100, 0.100, 0.100,
- SHININESS, 0.0,
- LMNULL } ;
-
- float GreenTankMaterial[] = {
- AMBIENT, 0.012, 0.062, 0.018,
- DIFFUSE, 0.120, 0.620, 0.180,
- SPECULAR, 0.093, 0.080, 0.064,
- SHININESS, 10,
- LMNULL } ;
-
- float BlueTankMaterial[] = {
- AMBIENT, 0.000, 0.038, 0.100,
- DIFFUSE, 0.000, 0.380, 1.000,
- SPECULAR, 0.000, 0.076, 0.200,
- SHININESS, 10,
- LMNULL } ;
-
- float RedTankMaterial[] = {
- AMBIENT, 0.100, 0.010, 0.010,
- DIFFUSE, 1.000, 0.100, 0.100,
- SPECULAR, 0.200, 0.020, 0.020,
- SHININESS, 10,
- LMNULL } ;
-
- float MissileMaterial[] = {
- AMBIENT, 0.561, 0.480, 0.387,
- DIFFUSE, 0.500, 0.500, 0.500,
- SPECULAR, 0.500, 0.500, 0.500,
- SHININESS, 40,
- LMNULL } ;
-
- float ManMaterial[] = {
- AMBIENT, 0.100, 0.100, 0.100,
- DIFFUSE, 0.500, 0.500, 0.500,
- SPECULAR, 0.100, 0.100, 0.100,
- SHININESS, 0,
- LMNULL } ;
-
- float BlackMaterial[] = {
- AMBIENT, 0.000, 0.000, 0.000,
- DIFFUSE, 0.000, 0.000, 0.000,
- SPECULAR, 0.000, 0.000, 0.000,
- SHININESS, 0,
- LMNULL } ;
-
- /*
- POSITION, 0.866, 0.000, 0.500, 0.000,
- POSITION, 0.000, 1.000, 0.000, 0.000, South
- POSITION, 0.000,-1.000, 0.000, 0.000, North
- POSITION, 0.000, 0.000,-1.000, 0.000, Above
- POSITION, 1.000, 0.000, 0.000, 0.000, West
- POSITION,-1.000, 0.000, 0.000, 0.000, East
- */
-
- float Light1[] = {
- LCOLOR, 1.000, 1.000, 1.000,
- POSITION, 0.612, 0.353,-0.707, 0.000,
- AMBIENT, 0.300, 0.300, 0.300,
- LMNULL } ;
- float Light2[] = {
- LCOLOR, 1.000, 1.000, 1.000,
- POSITION,-0.300,-0.640,-0.707, 0.000,
- AMBIENT, 0.300, 0.300, 0.300,
- LMNULL } ;
-
- float LModel[] = {
- AMBIENT, .2, .2, .2,
- LOCALVIEWER, 0.0,
- LMNULL } ;
-
-
- void init_lighting( void )
- {
- lmdef( DEFMATERIAL, OBSTACLE_MATERIAL, 0, ObstacleMaterial ) ;
- lmdef( DEFMATERIAL, GREEN_TANK_MATERIAL, 0, GreenTankMaterial ) ;
- lmdef( DEFMATERIAL, BLUE_TANK_MATERIAL, 0, BlueTankMaterial ) ;
- lmdef( DEFMATERIAL, RED_TANK_MATERIAL, 0, RedTankMaterial ) ;
- lmdef( DEFMATERIAL, MISSILE_MATERIAL, 0, MissileMaterial ) ;
- lmdef( DEFMATERIAL, MAN_MATERIAL, 0, ManMaterial ) ;
- lmdef( DEFLIGHT, 1, 0, Light1 ) ;
- lmdef( DEFLIGHT, 2, 0, Light2 ) ;
- lmdef( DEFLMODEL, 1, 0, LModel ) ;
-
- makeobj( lights_on = obj_count++ ) ;
- lmbind( LIGHT0, 1 ) ;
- lmbind( LIGHT1, 2 ) ;
- closeobj() ;
-
- makeobj( lights_off = obj_count++ ) ;
- lmbind( LIGHT0, 0 ) ;
- lmbind( LIGHT1, 0 ) ;
- closeobj() ;
- }
-
-
-
- void bind_lighting( void )
- {
- lmbind( LMODEL, 1 ) ;
- }
-
-
-
- static void set_mapcolor(
- Colormap cmap,
- unsigned long i,
- unsigned short r,
- unsigned short g,
- unsigned short b
- )
- {
- XColor c ;
- int st ;
-
- c.pixel = i ;
- c.red = r << 8 ;
- c.green = g << 8 ;
- c.blue = b << 8 ;
- c.flags = DoRed | DoGreen | DoBlue ;
- st = XStoreColor( display, cmap, &c ) ;
- }
-
-
-
- void init_color(
- int map,
- Widget widget
- )
- {
- int db_bits ;
- Colormap cmap ;
- int n ;
- Arg args[5] ;
- XVisualInfo *visualInfo ;
-
- n = 0 ;
- XtSetArg( args[n], XtNvisual, &visualInfo ) ; n++ ;
- XtGetValues( widget, args, n ) ;
-
- /*
- printf( "vid = 0x%08x, depth = %d, class = %d, colormapsize = %d, bpr = %d\n", visualInfo->visualid, visualInfo->depth, visualInfo->class, visualInfo->colormap_size, visualInfo->bits_per_rgb ) ;
- printf( "map = %d\n", map ) ;
- printf( "mvRGBmode: %d\n", mv_RGB ) ;
- */
-
- if( map == MAIN_VIEW_MAP && mv_RGB ) {
- mv_black = 0x00000000 ;
- mv_red = 0x000000ff ;
- mv_green = 0x0000ff00 ;
- mv_yellow = 0x0000ffff ;
- mv_white = 0x00ffffff ;
- mv_ground_color = 0x006c90ba ;
- tankMaterial[NEUTRAL_TEAM] = GREEN_TANK_MATERIAL ;
- tankMaterial[RED_TEAM] = RED_TANK_MATERIAL ;
- tankMaterial[BLUE_TEAM] = BLUE_TANK_MATERIAL ;
- return ;
- }
-
- if( visualInfo->class != TrueColor ) {
- cmap = XCreateColormap( XtDisplay( toplevel ), XtWindow( widget ),
- visualInfo->visual, AllocAll ) ;
- n = 0 ;
- XtSetArg( args[n], XtNcolormap, cmap ) ; n++ ;
- XtSetValues( widget, args, n ) ;
- }
-
- db_bits = getgdesc( GD_BITS_NORM_DBL_CMODE ) ;
- #if defined(INDIGO)
- db_bits = 4 ;
- #endif /* defined(INDIGO) */
-
- /*
- * If main view is in RGB mode, we only need the following colors:
- * green, red, blue, yellow, black, red, and ramp colors.
- */
- if( mv_RGB ) {
- black = 0 ;
- red = 1 ;
- green = 2 ;
- yellow = 3 ;
- blue = 6 ;
- white = 7 ;
- ground_color = 12 ;
- set_mapcolor( cmap, black, 0, 0, 0 ) ;
- set_mapcolor( cmap, red, 255, 0, 0 ) ;
- set_mapcolor( cmap, green, 0, 255, 0 ) ;
- set_mapcolor( cmap, yellow, 255, 255, 0 ) ;
- set_mapcolor( cmap, blue, 0, 128, 255 ) ;
- set_mapcolor( cmap, white, 255, 255, 255 ) ;
- set_mapcolor( cmap, ground_color, 186, 131, 85 ) ;
- }
- else {
- /*
- * Colors to be used by main view.
- */
- if( db_bits < 8 ) {
- t00[NEUTRAL_TEAM] = 1 ;
- t01[NEUTRAL_TEAM] = t00[NEUTRAL_TEAM] ;
- t02[NEUTRAL_TEAM] = 2 ;
- t03[NEUTRAL_TEAM] = t02[NEUTRAL_TEAM] ;
- t04[NEUTRAL_TEAM] = t02[NEUTRAL_TEAM] ;
- t05[NEUTRAL_TEAM] = t02[NEUTRAL_TEAM] ;
- t06[NEUTRAL_TEAM] = 3 ;
- t07[NEUTRAL_TEAM] = t06[NEUTRAL_TEAM] ;
-
- t00[RED_TEAM] = 5 ;
- t01[RED_TEAM] = t00[RED_TEAM] ;
- t02[RED_TEAM] = 6 ;
- t03[RED_TEAM] = t02[RED_TEAM] ;
- t04[RED_TEAM] = t02[RED_TEAM] ;
- t05[RED_TEAM] = t02[RED_TEAM] ;
- t06[RED_TEAM] = 7 ;
- t07[RED_TEAM] = t06[RED_TEAM] ;
-
- t00[BLUE_TEAM] = 9 ;
- t01[BLUE_TEAM] = t00[BLUE_TEAM] ;
- t02[BLUE_TEAM] = 10 ;
- t03[BLUE_TEAM] = t02[BLUE_TEAM] ;
- t04[BLUE_TEAM] = t02[BLUE_TEAM] ;
- t05[BLUE_TEAM] = t02[BLUE_TEAM] ;
- t06[BLUE_TEAM] = 11 ;
- t07[BLUE_TEAM] = t06[BLUE_TEAM] ;
-
- set_mapcolor( cmap, t00[NEUTRAL_TEAM], 31, 158, 46 ) ;
- set_mapcolor( cmap, t02[NEUTRAL_TEAM], 25, 127, 38 ) ;
- set_mapcolor( cmap, t06[NEUTRAL_TEAM], 18, 92, 27 ) ;
-
- set_mapcolor( cmap, t00[RED_TEAM], 181, 18, 0 ) ;
- set_mapcolor( cmap, t02[RED_TEAM], 135, 14, 0 ) ;
- set_mapcolor( cmap, t06[RED_TEAM], 90, 9, 0 ) ;
-
- set_mapcolor( cmap, t00[BLUE_TEAM], 0, 96, 255 ) ;
- set_mapcolor( cmap, t02[BLUE_TEAM], 0, 68, 181 ) ;
- set_mapcolor( cmap, t06[BLUE_TEAM], 0, 40, 107 ) ;
-
- o00 = 13 ;
- o01 = 14 ;
- o02 = o01 ;
- o03 = o00 ;
- o04 = o00 ;
- o05 = o01 ;
- o06 = o01 ;
- o07 = o00 ;
- set_mapcolor( cmap, o00, 68, 34, 26 ) ;
- set_mapcolor( cmap, o01, 128, 76, 51 ) ;
-
- m00 = t06[NEUTRAL_TEAM] ;
- m01 = t02[NEUTRAL_TEAM] ;
- m02 = t01[NEUTRAL_TEAM] ;
- m03 = m00 ;
-
- black = 0 ;
- yellow = 4 ;
- white = 8 ;
- red = 15 ;
- ground_color = 12 ;
- set_mapcolor( cmap, black, 0, 0, 0 ) ;
- set_mapcolor( cmap, red, 255, 0, 0 ) ;
- set_mapcolor( cmap, yellow, 255, 255, 0 ) ;
- set_mapcolor( cmap, white, 255, 255, 255 ) ;
- set_mapcolor( cmap, ground_color, 186, 131, 85 ) ;
- }
- else {
- t00[NEUTRAL_TEAM] = 16 ;
- t01[NEUTRAL_TEAM] = 17 ;
- t02[NEUTRAL_TEAM] = 18 ;
- t03[NEUTRAL_TEAM] = 19 ;
- t04[NEUTRAL_TEAM] = 20 ;
- t05[NEUTRAL_TEAM] = 21 ;
- t06[NEUTRAL_TEAM] = 22 ;
- t07[NEUTRAL_TEAM] = 23 ;
-
- set_mapcolor( cmap, t00[NEUTRAL_TEAM], 31, 158, 46 ) ;
- set_mapcolor( cmap, t01[NEUTRAL_TEAM], 28, 143, 42 ) ;
- set_mapcolor( cmap, t02[NEUTRAL_TEAM], 25, 127, 38 ) ;
- set_mapcolor( cmap, t03[NEUTRAL_TEAM], 24, 122, 36 ) ;
- set_mapcolor( cmap, t04[NEUTRAL_TEAM], 22, 112, 33 ) ;
- set_mapcolor( cmap, t05[NEUTRAL_TEAM], 20, 102, 31 ) ;
- set_mapcolor( cmap, t06[NEUTRAL_TEAM], 18, 92, 27 ) ;
- set_mapcolor( cmap, t07[NEUTRAL_TEAM], 15, 76, 23 ) ;
-
- t00[RED_TEAM] = 32 ;
- t01[RED_TEAM] = 33 ;
- t02[RED_TEAM] = 34 ;
- t03[RED_TEAM] = 35 ;
- t04[RED_TEAM] = 36 ;
- t05[RED_TEAM] = 37 ;
- t06[RED_TEAM] = 38 ;
- t07[RED_TEAM] = 39 ;
-
- set_mapcolor( cmap, t00[RED_TEAM], 181, 18, 0 ) ;
- set_mapcolor( cmap, t01[RED_TEAM], 158, 16, 0 ) ;
- set_mapcolor( cmap, t02[RED_TEAM], 135, 14, 0 ) ;
- set_mapcolor( cmap, t03[RED_TEAM], 125, 12, 0 ) ;
- set_mapcolor( cmap, t04[RED_TEAM], 115, 11, 0 ) ;
- set_mapcolor( cmap, t05[RED_TEAM], 102, 10, 0 ) ;
- set_mapcolor( cmap, t06[RED_TEAM], 90, 9, 0 ) ;
- set_mapcolor( cmap, t07[RED_TEAM], 58, 6, 0 ) ;
-
- t00[BLUE_TEAM] = 48 ;
- t01[BLUE_TEAM] = 49 ;
- t02[BLUE_TEAM] = 50 ;
- t03[BLUE_TEAM] = 51 ;
- t04[BLUE_TEAM] = 52 ;
- t05[BLUE_TEAM] = 53 ;
- t06[BLUE_TEAM] = 54 ;
- t07[BLUE_TEAM] = 55 ;
- set_mapcolor( cmap, t00[BLUE_TEAM], 0, 96, 255 ) ;
- set_mapcolor( cmap, t01[BLUE_TEAM], 0, 82, 218 ) ;
- set_mapcolor( cmap, t02[BLUE_TEAM], 0, 68, 181 ) ;
- set_mapcolor( cmap, t03[BLUE_TEAM], 0, 61, 162 ) ;
- set_mapcolor( cmap, t04[BLUE_TEAM], 0, 54, 144 ) ;
- set_mapcolor( cmap, t05[BLUE_TEAM], 0, 47, 125 ) ;
- set_mapcolor( cmap, t06[BLUE_TEAM], 0, 40, 107 ) ;
- set_mapcolor( cmap, t07[BLUE_TEAM], 0, 28, 74 ) ;
-
- o00 = 24 ;
- o01 = 25 ;
- o02 = 26 ;
- o03 = 27 ;
- o04 = 28 ;
- o05 = 29 ;
- o06 = 30 ;
- o07 = 31 ;
- set_mapcolor( cmap, o00, 68, 34, 26 ) ;
- set_mapcolor( cmap, o01, 128, 76, 51 ) ;
- set_mapcolor( cmap, o02, 128, 76, 51 ) ;
- set_mapcolor( cmap, o03, 68, 34, 26 ) ;
- set_mapcolor( cmap, o04, 119, 68, 51 ) ;
- set_mapcolor( cmap, o05, 170, 94, 60 ) ;
- set_mapcolor( cmap, o06, 170, 94, 60 ) ;
- set_mapcolor( cmap, o07, 119, 68, 51 ) ;
-
- m00 = 40 ;
- m01 = 41 ;
- m02 = 42 ;
- m03 = 43 ;
- set_mapcolor( cmap, m00, 225, 225, 225 ) ;
- set_mapcolor( cmap, m01, 175, 175, 175 ) ;
- set_mapcolor( cmap, m02, 125, 125, 125 ) ;
- set_mapcolor( cmap, m03, 100, 100, 100 ) ;
-
- black = 0 ;
- yellow = 3 ;
- white = 7 ;
- red = 1 ;
- ground_color = 44 ;
- set_mapcolor( cmap, black, 0, 0, 0 ) ;
- set_mapcolor( cmap, red, 255, 0, 0 ) ;
- set_mapcolor( cmap, yellow, 255, 255, 0 ) ;
- set_mapcolor( cmap, white, 255, 255, 255 ) ;
- set_mapcolor( cmap, ground_color, 186, 131, 85 ) ;
- }
- /*
- * Remaining colors to be used by base view and radar view.
- */
- if( map != MAIN_VIEW_MAP ) {
- /*
- * Radar view colors (not defined by main view's colors).
- */
- if( db_bits < 8 ) {
- green = t00[NEUTRAL_TEAM] ;
- blue = t00[BLUE_TEAM] ;
- }
- else {
- green = 2 ;
- blue = 6 ;
- set_mapcolor( cmap, green, 0, 255, 0 ) ;
- set_mapcolor( cmap, blue, 0, 128, 255 ) ;
- }
- }
- }
- /*
- * Base view colors (not defined by other view's colors).
- * We should have at least 256 colors (checked in bzscreen.c).
- */
- ramp0 = 64 ;
- ramp1 = 73 ;
- ramp2 = 74 ;
- ramp3 = 127 ;
- ramp4 = 128 ;
-
- if( visualInfo->colormap_size >= ramp4 ) {
- make_ramp( cmap ) ;
- }
-
- XFlush( display ) ;
-
- return ;
- }
-
-
-
- short rampcolor[] = { 60,100,140,180,220,255,220,180,140,120 };
-
- static void make_ramp(
- Colormap cmap
- )
- {
- short c ;
- Colorindex i;
- int t_ramp = sizeof(rampcolor)/sizeof(rampcolor[0]) - 1 ;
-
- for( i = ramp2 ; i <= ramp3 ; i++ ) {
- if( ramp2 == ramp3 ) {
- c = 200 ;
- }
- else {
- c = (Colorindex)( (float)( i - ramp2 ) /
- (float)( ramp3 - ramp2 ) * 195.f + 60.f ) ;
- }
- set_mapcolor( cmap, i, c, c, c ) ;
- if( i == ramp3 ) {
- set_mapcolor( cmap, ramp4, c, c, c ) ;
- }
- }
- for( i = ramp0 ; i <= ramp1 ; i++ ) {
- c = rampcolor[(t_ramp*(i-ramp0))/(ramp1-ramp0)];
- set_mapcolor( cmap, i, c, c, c ) ;
- }
- }
-
-
-
-
- Fontchar chars[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- /* *+c */ 0, 0, 0, 0, 0, 0, 180,10,15, 0, 0,12, 0, 0, 0, 0, 0, 0,
- /* -./ */ 150,10,15, 0, 0,12, 165,10,15, 0, 0,12, 0, 0, 0, 0, 0, 0,
- /* 012 */ 0,10,15, 0, 0,12, 15,10,15, 0, 0,12, 30,10,15, 0, 0,12,
- /* 345 */ 45,10,15, 0, 0,12, 60,10,15, 0, 0,12, 75,10,15, 0, 0,12,
- /* 678 */ 90,10,15, 0, 0,12, 105,10,15, 0, 0,12, 120,10,15, 0, 0,12,
- /* 9 */ 135,10,15, 0, 0,12
- } ;
- unsigned short raster[] = {
- /* 0 */ 0xbf40,0x8040,0x8040,0x8040,0x8040,0x8040,0x8040,0x0000,
- 0x8040,0x8040,0x8040,0x8040,0x8040,0x8040,0xbf40,
- /* 1 */ 0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0000,
- 0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,
- /* 2 */ 0xbf00,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x3f00,
- 0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x3f40,
- /* 3 */ 0x3f00,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x3f00,
- 0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x3f40,
- /* 4 */ 0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x3f00,
- 0x8040,0x8040,0x8040,0x8040,0x8040,0x8040,0x8040,
- /* 5 */ 0x3f40,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x3f00,
- 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0xbf00,
- /* 6 */ 0x3f40,0x8040,0x8040,0x8040,0x8040,0x8040,0x8040,0x3f00,
- 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0xbf00,
- /* 7 */ 0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x0000,
- 0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x3f40,
- /* 8 */ 0xbf40,0x8040,0x8040,0x8040,0x8040,0x8040,0x8040,0x3f00,
- 0x8040,0x8040,0x8040,0x8040,0x8040,0x8040,0xbf40,
- /* 9 */ 0x3f40,0x0040,0x0040,0x0040,0x0040,0x0040,0x0040,0x3f00,
- 0x8040,0x8040,0x8040,0x8040,0x8040,0x8040,0xbf40,
- /* - */ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x3f00,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- /* . */ 0x0c00,0x0c00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- /* + */ 0xc000,0xc000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
- } ;
-
- static long digit_src_elem[][2] = {
- { 2, 0 }, /* 0 : bottom horiz */
- { 7, 0 },
- { 2, 7 }, /* 1 : mid horiz */
- { 7, 7 },
- { 2, 14 }, /* 2 : top horiz */
- { 7, 14 },
- { 0, 0 }, /* 3 : lower left vert */
- { 0, 6 },
- { 0, 8 }, /* 4 : upper left vert */
- { 0, 14 },
- { 9, 0 }, /* 5 : lower right vert */
- { 9, 6 },
- { 9, 8 }, /* 6 : upper right vert */
- { 9, 14 }
- } ;
-
- static long digit_src[] = {
- 1, /* 0 */
- 1,
- 0, 2, 3, 4, 5, 6,
- 5, /* 1 */
- 0, 1, 2, 3, 4,
- 5, 6,
- 2, /* 2 */
- 4, 5,
- 0, 1, 2, 3, 6,
- 2, /* 3 */
- 3, 4,
- 0, 1, 2, 5, 6,
- 3, /* 4 */
- 0, 2, 3,
- 1, 4, 5, 6,
- 2, /* 5 */
- 3, 6,
- 0, 1, 2, 4, 5,
- 1, /* 6 */
- 6,
- 0, 1, 2, 3, 4, 5,
- 4, /* 7 */
- 0, 1, 3, 4,
- 2, 5, 6,
- 0, /* 8 */
- 0, 1, 2, 3, 4, 5, 6,
- 1, /* 9 */
- 3,
- 0, 1, 2, 4, 5, 6,
- } ;
-
- static unsigned short halftone[] = {
- 0xaaaa, 0x5555,
- 0xaaaa, 0x5555,
- 0xaaaa, 0x5555,
- 0xaaaa, 0x5555,
- 0xaaaa, 0x5555,
- 0xaaaa, 0x5555,
- 0xaaaa, 0x5555,
- 0xaaaa, 0x5555
- } ;
-
-
-
- void make_fonts( void )
- {
- short fn ;
- short ht ;
- short nc ;
- short nr ;
- int i ;
- int j ;
- int k ;
- int l ;
- int n ;
-
- fn = 1 ;
- ht = 15 ;
- nc = 58 ;
- nr = 15*13 ;
- defrasterfont( fn, ht, nc, chars, nr, raster ) ;
-
- k = 0 ;
- for( i = 0 ; i < 10 ; i++ ) {
- digit[i][0] = obj_count++ ;
- makeobj( digit[i][0] = obj_count++ ) ;
- n = digit_src[k++] ;
- for( j = 0 ; j < n ; j++ ) {
- l = digit_src[k++] << 1 ;
- bgnline() ;
- v2i( digit_src_elem[l++] ) ;
- v2i( digit_src_elem[l] ) ;
- endline() ;
- }
- closeobj() ;
- digit[i][1] = obj_count++ ;
- makeobj( digit[i][1] = obj_count++ ) ;
- for( ; j < 7 ; j++ ) {
- l = digit_src[k++] << 1 ;
- bgnline() ;
- v2i( digit_src_elem[l++] ) ;
- v2i( digit_src_elem[l] ) ;
- endline() ;
- }
- closeobj() ;
- }
- defpattern( 1, 16, halftone ) ;
- }
-
-
-
- void make_pieces(
- unsigned exp_len
- )
- {
- unsigned i ;
- unsigned j ;
- unsigned k ;
- unsigned n_tank ;
- unsigned team ;
- unsigned sum ;
- Angle rx[5] ;
- Angle drx[5] ;
- Angle rx2[5] ;
- float x[5] ;
- float y[5] ;
- float z[5] ;
- float x00[5] ;
- float y00[5] ;
- float z00[5] ;
- float vx[5] ;
- float vy[5] ;
- float vz[5] ;
- float az ;
- float f[5] ;
- float ang ;
- float sin_ang ;
- float cos_ang ;
-
- for( i = 0 , sum = 0 ; i < exp_len-1 ; i++ ) sum += i ;
-
- if( showMan ) {
- makeobj( man_part = obj_count++ ) ;
- if( mv_RGB ) {
- lmbind( MATERIAL, MAN_MATERIAL ) ;
- shademodel( GOURAUD ) ;
- }
- else {
- color( white );
- }
- pushmatrix() ;
- rotate( 900, 'x' ) ;
-
- if( mv_RGB ) {
- ang = M_PI / 5.f ;
- draw_tcirc( 0.f, 2.0f, 0.5f, 20, 0, 1, ang ) ;
- }
- else {
- circf( 0.0f, 2.0f, 0.5f ) ;
- }
- sin_ang = fsin( ang ) ;
- cos_ang = fcos( ang ) ;
-
- bgntmesh() ;
- normal3f( -sin_ang, 0.f, cos_ang ) ;
- f[0] = -0.6f ; f[1] = 0.0f ; v2f( f ) ;
- normal3f( sin_ang, 0.f, cos_ang ) ;
- f[0] = 0.6f ; f[1] = 0.0f ; v2f( f ) ;
- normal3f( -sin_ang, 0.f, cos_ang ) ;
- f[0] = -0.6f ; f[1] = 1.6f ; v2f( f ) ;
- normal3f( sin_ang, 0.f, cos_ang ) ;
- f[0] = 0.6f ; f[1] = 1.6f ; v2f( f ) ;
- endtmesh() ;
- bgntmesh() ;
- normal3f( 0.f, -sin_ang, cos_ang ) ;
- f[0] = -0.6f ; f[1] = 1.5f ; v2f( f ) ;
- normal3f( 0.f, -sin_ang, cos_ang ) ;
- f[0] = -1.2f ; f[1] = 1.5f ; v2f( f ) ;
- normal3f( 0.f, sin_ang, cos_ang ) ;
- f[0] = -0.6f ; f[1] = 1.2f ; v2f( f ) ;
- normal3f( 0.f, sin_ang, cos_ang ) ;
- f[0] = -1.2f ; f[1] = 1.2f ; v2f( f ) ;
- endtmesh() ;
- bgntmesh() ;
- normal3f( 0.f, sin_ang, cos_ang ) ;
- f[0] = 0.6f ; f[1] = 1.2f ; v2f( f ) ;
- normal3f( 0.f, sin_ang, cos_ang ) ;
- f[0] = 1.2f ; f[1] = 1.2f ; v2f( f ) ;
- normal3f( 0.f, -sin_ang, cos_ang ) ;
- f[0] = 0.6f ; f[1] = 1.5f ; v2f( f ) ;
- normal3f( 0.f, -sin_ang, cos_ang ) ;
- f[0] = 1.2f ; f[1] = 1.5f ; v2f( f ) ;
- endtmesh() ;
- bgntmesh() ;
- normal3f( 0.f, -sin_ang, cos_ang ) ;
- f[0] = -1.2f ; f[1] = 1.5f ; v2f( f ) ;
- normal3f( 0.f, sin_ang, cos_ang ) ;
- f[0] = -1.2f ; f[1] = 1.2f ; v2f( f ) ;
- normal3f( 0.f, -sin_ang, cos_ang ) ;
- f[0] = -1.6f ; f[1] = 2.0f ; v2f( f ) ;
- normal3f( 0.f, sin_ang, cos_ang ) ;
- f[0] = -1.75f; f[1] = 1.8f ; v2f( f ) ;
- endtmesh() ;
- bgntmesh() ;
- normal3f( 0.f, sin_ang, cos_ang ) ;
- f[0] = 1.2f ; f[1] = 1.2f ; v2f( f ) ;
- normal3f( 0.f, -sin_ang, cos_ang ) ;
- f[0] = 1.2f ; f[1] = 1.5f ; v2f( f ) ;
- normal3f( 0.f, sin_ang, cos_ang ) ;
- f[0] = 1.75f; f[1] = 1.8f ; v2f( f ) ;
- normal3f( 0.f, -sin_ang, cos_ang ) ;
- f[0] = 1.6f ; f[1] = 2.0f ; v2f( f ) ;
- endtmesh() ;
- bgntmesh() ;
- normal3f( -sin_ang, 0.f, cos_ang ) ;
- f[0] = 0.3f ; f[1] = -2.2f ; v2f( f ) ;
- normal3f( sin_ang, 0.f, cos_ang ) ;
- f[0] = 0.8f ; f[1] = -2.2f ; v2f( f ) ;
- normal3f( -sin_ang, 0.f, cos_ang ) ;
- f[0] = 0.1f ; f[1] = 0.0f ; v2f( f ) ;
- normal3f( sin_ang, 0.f, cos_ang ) ;
- f[0] = 0.6f ; f[1] = 0.0f ; v2f( f ) ;
- endtmesh() ;
- bgntmesh() ;
- normal3f( -sin_ang, 0.f, cos_ang ) ;
- f[0] = -0.8f ; f[1] = -2.2f ; v2f( f ) ;
- normal3f( sin_ang, 0.f, cos_ang ) ;
- f[0] = -0.3f ; f[1] = -2.2f ; v2f( f ) ;
- normal3f( -sin_ang, 0.f, cos_ang ) ;
- f[0] = -0.6f ; f[1] = 0.0f ; v2f( f ) ;
- normal3f( sin_ang, 0.f, cos_ang ) ;
- f[0] = -0.1f ; f[1] = 0.0f ; v2f( f ) ;
- endtmesh() ;
- if( mv_RGB ) {
- shademodel( FLAT ) ;
- }
- popmatrix();
- closeobj();
- }
-
- for( n_tank = 0 ; n_tank < N_TYPES ; n_tank++ ) {
- az = 1.0f ;
- for( i = 0 ; i < 5 ; i++ ) {
- x[i] = y[i] = z[i] = 0.0f ;
- x00[i] = y00[i] = z00[i] = 0.0f ;
- rx2[i] = rx[i] = 0 ;
- drx[i] = (rand() % 500 + 200 ) ;
- vx[i] = (float)(rand() % 21 - 10 ) / 4.f ;
- vy[i] = (float)(rand() % 21 - 10 ) / 4.f ;
- vz[i] = (float)(rand() % 5 + 6 ) / 10.f * az *
- (float)(sum) / (float)(exp_len-1) ;
- }
-
- x00[0] = 0.f ;
- y00[0] = (QY04+QY09)/2.f ;
- z00[0] = (QZ04+QZ10)/2.f ;
- x00[1] = 0.f ;
- y00[1] = (n_tank) ? (QY07+QY13)/2.f : (PY07+PY09)/2.f ;
- z00[1] = (n_tank) ? (QZ05+QZ07)/2.f : (PZ03+PZ04)/2.f ;
- x00[2] = (n_tank) ? QX01 : PX01 ;
- y00[2] = (n_tank) ? (QY02+QY12)/2.f : (PY01+PY08)/2.f ;
- z00[2] = (n_tank) ? (QZ01+QZ08)/2.f : (PZ01+PZ06)/2.f ;
- x00[3] = 0.f ;
- y00[3] = 0.f ;
- z00[3] = 0.f ;
- x00[4] = 0.f ;
- y00[4] = (n_tank) ? (QY01+QY03)/2.f : (PY01+PY02)/2.f ;
- z00[4] = (n_tank) ? (QZ01+QZ08)/2.f : (PZ01+PZ06)/2.f ;
-
- for( i = 0 ; i < exp_len ; i++ ) {
- for( k = 0 ; k < N_TEAMS ; k++ ) {
- makeobj( explosion[k][i][n_tank] = obj_count++ ) ;
- if( mv_RGB ) {
- team = 0 ;
- lmbind( MATERIAL, tankMaterial[k] ) ;
- }
- else {
- team = k ;
- }
-
- pushmatrix();
- translate(x[0],y[0],z[0]);
- rotate(-rx[0],'x');
- translate(-x00[0],-y00[0],-z00[0]);
- callobj(front_pit[team][n_tank]);
- callobj(right_pit[team][n_tank]);
- callobj( left_pit[team][n_tank]);
- callobj( back_pit[team][n_tank]);
- popmatrix();
-
- pushmatrix();
- translate(x[1],y[1],z[1]);
- rotate( rx[1],'x');
- translate(-x00[1],-y00[1],-z00[1]);
- callobj(right_barrel[team][n_tank]);
- callobj( left_barrel[team][n_tank]);
- callobj(front_barrel[team][n_tank]);
- popmatrix();
-
- pushmatrix();
- translate(x[2],y[2],z[2]);
- rotate( rx[2],'y');
- rotate( rx2[2],'y');
- translate(-x00[2],-y00[2],-z00[2]);
- callobj(right[team][n_tank]);
- popmatrix();
-
- pushmatrix();
- scale(-1.f,1.f,1.f);
- translate(x[2],y[2],z[2]);
- rotate(-rx[2],'y');
- rotate(-rx2[2],'y');
- translate(-x00[2],-y00[2],-z00[2]);
- callobj(right[team][n_tank]);
- popmatrix();
-
- pushmatrix();
- translate(x[4],y[4],z[4]);
- rotate( rx[4],'z');
- rotate( rx2[4],'x');
- translate(-x00[4],-y00[4],-z00[4]);
- callobj(back[team][n_tank]);
- popmatrix();
-
- if( showMan ) {
- pushmatrix();
- translate(x[3],y[3],z[3]);
- scale(-1.f,1.f,1.f);
- rotate(-rx[3],'x');
- rotate( rx2[3],'x');
- translate(-x00[3],-y00[3],-z00[3]);
- callobj(man_part);
- popmatrix();
- }
-
- closeobj();
- }
- for( j = 0 ; j < 5 ; j++ ) {
- x[j] += vx[j] ;
- y[j] += vy[j] ;
- z[j] += vz[j] ;
- rx[j] += drx[j] ;
- if( z[j] <= 0.0f ) {
- z[j] = 0.0f ;
- vx[j] = 0.0f ;
- vy[j] = 0.0f ;
- vz[j] = 0.0f ;
- drx[j] = 0 ;
- switch(j) {
- case 0:
- rx[j] = 0 ;
- break ;
- case 1:
- rx[j] = 0 ;
- break ;
- case 2:
- rx[j] = 0 ;
- rx2[j] = 900 ;
- break ;
- case 3:
- rx[j] = 0 ;
- rx2[j] = 900 ;
- break ;
- case 4:
- rx[j] = 0 ;
- switch( n_tank ) {
- case 0 :
- rx2[j] = 900 ;
- break ;
- case 1 :
- rx2[j] = -700 ;
- break ;
- case 2 :
- rx2[j] = -400 ;
- break ;
- }
- break ;
- }
- }
- vz[j] -= az ;
- }
- }
- }
- }
-
-
-
- void make_obst( void )
- {
- int i ;
- int v ;
- unsigned long *imagedata ;
- static float texps[] = { TX_MINFILTER, TX_MIPMAP_BILINEAR,
- TX_MAGFILTER, TX_BILINEAR, TX_NULL } ;
- static float tevps[] = { TV_NULL } ;
- static char *tex_file = "/usr/demos/data/textures/guarana.rgb" ;
-
- if( use_textures ) {
- if( access( tex_file, R_OK ) < 0 ) {
- perror( tex_file ) ;
- use_textures = FALSE ;
- }
- else {
- imagedata = (unsigned long *)longimagedata( tex_file ) ;
- if( imagedata == NULL ) {
- use_textures = FALSE ;
- fprintf( stderr, "%s: can't open texture file `%s':", basename,
- tex_file ) ;
- }
- else {
- texdef2d( 1, 4, 128, 128, imagedata,
- sizeof( texps ) / sizeof( texps[0] ), texps ) ;
- tevdef( 1, sizeof( tevps ) / sizeof( tevps[0] ), tevps ) ;
- }
- }
- }
-
- for( v = 0 ; v < N_VIEWS ; v++ ) {
- makeobj( cube[v] = obj_count++ ) ;
-
- if( mv_RGB ) {
- lmbind( MATERIAL, OBSTACLE_MATERIAL ) ;
-
- if( use_textures ) {
- tevbind( TV_ENV0, 1 ) ;
- texbind( TX_TEXTURE_0, 1 ) ;
- }
- }
-
- for( i = 0 ; i < 4 ; i++ ) {
- switch( order_obst[v][i] ) {
- case FRON:
- if( !mv_RGB ) color( o00 ) ;
- draw_tex_surface( cube_front ) ;
- break;
- case RIGH:
- if( !mv_RGB ) color( o01 ) ;
- draw_tex_surface( cube_right ) ;
- break;
- case LEFT:
- if( !mv_RGB ) color( o02 ) ;
- draw_tex_surface( cube_left ) ;
- break;
- case BACK:
- if( !mv_RGB ) color( o03 ) ;
- draw_tex_surface( cube_back ) ;
- break;
- case NADA:
- break;
- }
- }
-
- if( use_textures )
- texbind( TX_TEXTURE_0, 0 ) ;
-
- closeobj();
- }
-
- for( v = 0 ; v < N_VIEWS ; v++ ) {
- makeobj( pyrm[v] = obj_count++ ) ;
- if( mv_RGB ) {
- lmbind( MATERIAL, OBSTACLE_MATERIAL ) ;
-
- if( use_textures ) {
- tevbind( TV_ENV0, 1 ) ;
- texbind( TX_TEXTURE_0, 1 ) ;
- }
- }
-
- for( i = 0 ; i < 4 ; i++ ) {
- switch( order_obst[v][i] ) {
- case FRON:
- if( !mv_RGB ) color( o04 ) ;
- draw_tex_surface( pyrm_front ) ;
- break;
- case RIGH:
- if( !mv_RGB ) color( o05 ) ;
- draw_tex_surface( pyrm_right ) ;
- break;
- case LEFT:
- if( !mv_RGB ) color( o06 ) ;
- draw_tex_surface( pyrm_left ) ;
- break;
- case BACK:
- if( !mv_RGB ) color( o07 ) ;
- draw_tex_surface( pyrm_back ) ;
- break;
- case NADA:
- break;
- }
- }
-
- if( use_textures )
- texbind( TX_TEXTURE_0, 0 ) ;
-
- closeobj();
- }
- }
-
-
-
- void make_flags( void )
- {
- int i ;
- int v ;
- int team ;
-
- for( team = 1 ; team < N_FLAGS + 1 ; team++ ) {
- for( v = 0 ; v < N_VIEWS ; v++ ) {
- makeobj( flag[team-1][v] = obj_count++ ) ;
-
- if( mv_RGB ) {
- lmbind( MATERIAL, tankMaterial[team] ) ;
- }
-
- for( i = 0 ; i < 4 ; i++ ) {
- switch( order_obst[v][i] ) {
- case FRON:
- if( !mv_RGB ) color( t00[team] ) ;
- draw_surface( flag_front_top ) ;
- if( !mv_RGB ) color( t07[team] ) ;
- draw_surface( flag_front_bot ) ;
- break;
- case RIGH:
- if( !mv_RGB ) color( t02[team] ) ;
- draw_surface( flag_right_top ) ;
- if( !mv_RGB ) color( t07[team] ) ;
- draw_surface( flag_right_bot ) ;
- break;
- case LEFT:
- if( !mv_RGB ) color( t04[team] ) ;
- draw_surface( flag_left_top ) ;
- if( !mv_RGB ) color( t07[team] ) ;
- draw_surface( flag_left_bot ) ;
- break;
- case BACK:
- if( !mv_RGB ) color( t06[team] ) ;
- draw_surface( flag_back_top ) ;
- if( !mv_RGB ) color( t07[team] ) ;
- draw_surface( flag_back_bot ) ;
- break;
- case NADA:
- break;
- }
- }
-
- closeobj();
- }
- }
- }
-
-
-
- GL_Object read_logo(
- const char *filename,
- unsigned char *logodata,
- int size,
- int set_color,
- int *logo_side
- )
- {
- FILE *f ;
- char line[128] ;
- int n = 0 ;
- int npts ;
- int x ;
- int y ;
- int version ;
- int global = 1 ;
- int ln = 0 ;
- int nbtm = 0 ;
-
- if( ( f = fopen( filename, "r" ) ) == NULL ) {
- perror( filename ) ;
- return( 0 ) ;
- }
-
- fgets( line, sizeof( line ), f ) ;
- ln++ ;
-
- if( strcmp( line, "# BZLOGO Version 1.1\n" ) == 0 ) {
- version = 11 ;
- }
- else if( strcmp( line, "# BZLOGO Version 1.0\n" ) == 0 ) {
- version = 10 ;
- global = 0 ;
- }
- else {
- fclose( f ) ;
- fprintf( stderr, "read_logo: bad magic number in logo file.\n" ) ;
- return( 0 ) ;
- }
-
- while( 1 ) {
- if( fgets( line, sizeof( line ), f ) == NULL ) {
- fclose( f ) ;
- fprintf( stderr, "read_logo: premature end of file.\n" ) ;
- return( 0 ) ;
- }
- ln++ ;
-
- if( strcmp( line, "BGNTMESH\n" ) == 0 ) {
- if( nbtm > 0 ) {
- fprintf( stderr, "read_logo: error on line %d -- embedded call "
- "to BGNTMESH (use ENDBGNTMESH)\n", ln ) ;
- return( 0 ) ;
- }
- nbtm = 1 ;
- global = 0 ;
- logodata[n++] = BZL_BGNTMESH ;
- }
- else if( strcmp( line, "SWAPTMESH\n" ) == 0 ) {
- global = 0 ;
- logodata[n++] = BZL_SWAPTMESH ;
- }
- else if( strcmp( line, "ENDBGNTMESH\n" ) == 0 ) {
- global = 0 ;
- logodata[n++] = BZL_ENDBGNTMESH ;
- }
- else if( strcmp( line, "RETENDTMESH\n" ) == 0 ) {
- global = 0 ;
- logodata[n++] = BZL_RETENDTMESH ;
- break ;
- }
- else if( global == 1 && strcmp( line, "LEFTSIDE\n" ) == 0 ) {
- logodata[n++] = BZL_LEFTSIDE ;
- }
- else if( global == 1 && strcmp( line, "RIGHTSIDE\n" ) == 0 ) {
- logodata[n++] = BZL_RIGHTSIDE ;
- }
- else {
- fclose( f ) ;
- fprintf( stderr, "read_logo: error reading logo file.\n" ) ;
- return( 0 ) ;
- }
-
- if( global ) {
- npts = 0 ;
- }
- else {
- if( fscanf( f, "%d", &npts ) != 1 || npts < 1 ) {
- fclose( f ) ;
- fprintf( stderr, "read_logo: error reading logo file.\n" ) ;
- return( 0 ) ;
- }
- ln++ ;
-
- /*
- * Check size of logo:
- *
- * NUMBER_PTS_ALREADY + NEXT_CMD + N_PTS + N_PTS * 2
- */
- if( n + 2 + 2 * npts >= size ) {
- fclose( f ) ;
- fprintf( stderr, "read_logo: logo too big "
- "(maximum of %d words)\n", size ) ;
- return( 0 ) ;
- }
-
- logodata[n++] = npts ;
-
- while( npts-- ) {
- if( fscanf( f, "%d %d", &x, &y ) != 2 || x < 0 || y < 0 ||
- x > 255 || y > 255 ) {
- fclose( f ) ;
- fprintf( stderr, "read_logo: error reading logo file.\n" ) ;
- return( 0 ) ;
- }
- ln++ ;
- logodata[n++] = x ;
- logodata[n++] = y ;
- }
-
- /*
- * Get trailing line feed.
- */
- if( fgetc( f ) != '\n' ) {
- fclose( f ) ;
- fprintf( stderr, "read_logo: error reading logo file.\n" ) ;
- return( 0 ) ;
- }
- }
- }
-
- fclose( f ) ;
-
- return( create_logo( logodata, set_color, logo_side ) ) ;
- }
-
-
-
- GL_Object create_logo(
- unsigned char *logodata,
- int set_color,
- int *logo_side
- )
- {
- GL_Object obj ;
- unsigned char glyph ;
- int npts ;
- int expect_points ;
- float pt[2] ;
- static float n[3] = { 0., 1., 0. } ;
-
- *logo_side = BZL_NOSIDE ;
-
- makeobj( obj = obj_count++ ) ;
-
- if( set_color ) {
- if( mv_RGB ) {
- cpack( 0x0 ) ;
- }
- else {
- color( black ) ;
- }
- }
-
- while( ( glyph = *(logodata++) ) != BZL_RETENDTMESH ) {
- switch( glyph ) {
- case BZL_BGNTMESH :
- bgntmesh() ;
- expect_points = 1 ;
- break ;
- case BZL_SWAPTMESH :
- swaptmesh() ;
- expect_points = 1 ;
- break ;
- case BZL_ENDBGNTMESH :
- endtmesh() ;
- bgntmesh() ;
- expect_points = 1 ;
- break ;
- case BZL_LEFTSIDE :
- case BZL_RIGHTSIDE :
- *logo_side = glyph ;
- expect_points = 0 ;
- break ;
- default :
- obj_count-- ;
- closeobj() ;
- delobj( obj ) ;
- fprintf( stderr, "create_logo: bad logo info\n" ) ;
- return( 0 ) ;
- }
-
- if( expect_points ) {
- npts = *(logodata++) ;
- while( npts > 0 ) {
- pt[0] = *(logodata++) ;
- pt[1] = *(logodata++) ;
- v2f( pt ) ;
- npts-- ;
- }
- }
- }
- endtmesh() ;
- closeobj() ;
-
- return( obj ) ;
- }
-
-
-
- static void show_logo(
- GL_Object logo,
- int type,
- int is_right,
- int side
- )
- {
- static float logo_offset[] = { -6.50, -5.00, -4.00 } ;
-
- if( show_logos && logo ) {
- pushmatrix() ;
- if( is_right ) {
- if( side == BZL_LEFTSIDE ) {
- translate( QX01, logo_offset[type]+1.28f, 0.5f ) ;
- rot( -90.0f, 'z' ) ;
- }
- else {
- translate( QX01, logo_offset[type]-1.28f, 0.5f ) ;
- rot( 90.0f, 'z' ) ;
- }
- }
- else {
- if( side == BZL_RIGHTSIDE ) {
- translate( -QX01, logo_offset[type]-1.28f, 0.5f ) ;
- rot( 90.0f, 'z' ) ;
- }
- else {
- translate( -QX01, logo_offset[type]+1.28f, 0.5f ) ;
- rot( -90.0f, 'z' ) ;
- }
- }
- rot( 90.0f, 'x' ) ;
- scale( 0.0100f, 0.0100f, 0.0100f ) ;
- callobj( logo ) ;
- popmatrix() ;
- }
- }
-
-